package top.heue.temp.activity.error

import androidx.appcompat.widget.Toolbar
import com.orhanobut.hawk.Hawk
import top.heue.temp.R
import top.heue.temp.app.T
import top.heue.temp.app.Values
import top.heue.utils.base.util.system.SystemUtil
import top.heue.utils.lifecycle.base.BaseModel

class ErrorModel : BaseModel() {
    private val errorArray: Array<String> = Hawk.get(Values.TAG_ERROR)
    lateinit var restart: () -> Unit
    val menuOnclick = Toolbar.OnMenuItemClickListener {
        when (it.itemId) {
            R.id.menu_report -> T.show("未开发提交反馈")
            R.id.menu_restart -> restart()
        }
        true
    }

    val message: String by lazy { errorArray[1] }

    fun init(activity: ErrorActivity) {
        restart = { SystemUtil.restart(activity) }
    }
}